1 00:00:00,600 --> 00:00:02,750 Now let's get Ralph to walk around a little bit. 2 00:00:02,760 --> 00:00:04,380 Ralph is our NPC. 3 00:00:04,410 --> 00:00:06,390 I'm going to use the simplest method. 4 00:00:06,390 --> 00:00:09,090 I'm going to put some waypoints down, right? 5 00:00:09,090 --> 00:00:15,540 So I'm just going to put a part and then I'm going to say WP for Waypoint if I can get that. 6 00:00:15,810 --> 00:00:16,790 There you go. 7 00:00:16,800 --> 00:00:27,390 WP And I'll make it smaller, maybe make the size one by one by one and we're going to anchor it. 8 00:00:27,990 --> 00:00:34,620 There's anchored, click anchored, go up a little bit, can collide off and let's make it invisible. 9 00:00:36,880 --> 00:00:38,010 Well, let's make it. 10 00:00:38,020 --> 00:00:42,610 We're going to make it invisible, but let's make it partially invisible so we can still kind of see 11 00:00:42,610 --> 00:00:43,880 it while we're working on it. 12 00:00:43,900 --> 00:00:46,420 We'll make it all the way invisible when we're done. 13 00:00:46,750 --> 00:00:48,580 So we've got a little part right there. 14 00:00:49,270 --> 00:00:50,200 Let's add a couple of them. 15 00:00:50,200 --> 00:00:54,760 Let's do a control D to duplicate that control de. 16 00:00:56,660 --> 00:00:59,050 Control day air. 17 00:00:59,090 --> 00:01:00,380 We got a few waypoints. 18 00:01:00,380 --> 00:01:01,790 We've got a little square going. 19 00:01:02,150 --> 00:01:04,130 Let's grab all those waypoints. 20 00:01:04,130 --> 00:01:06,110 Click then chef click. 21 00:01:06,320 --> 00:01:09,380 Right click group as folder. 22 00:01:09,380 --> 00:01:10,370 Let's do folder. 23 00:01:10,370 --> 00:01:11,900 It works for model two. 24 00:01:11,900 --> 00:01:13,340 It's your choice. 25 00:01:13,340 --> 00:01:16,240 I'm going to call these w p. 26 00:01:16,250 --> 00:01:18,320 S waypoints with the capital. 27 00:01:18,320 --> 00:01:20,840 W I think I'm going to move them inside. 28 00:01:20,840 --> 00:01:21,200 Ralph. 29 00:01:21,200 --> 00:01:24,080 I'm just going to keep my waypoints inside my MPC. 30 00:01:24,800 --> 00:01:31,760 Now on Ralph, let's add a script to make them walk around, make them walk to those waypoints and it's 31 00:01:31,760 --> 00:01:35,060 called a script move. 32 00:01:35,060 --> 00:01:40,190 And P.S., let's get rid of our print statement on our Move MPC script. 33 00:01:40,190 --> 00:01:41,030 There we go. 34 00:01:41,030 --> 00:01:44,840 And let's get a variable for the character for Ralph, right? 35 00:01:44,840 --> 00:01:52,190 So we have our script script parent There's the script, Ralph's the parent, and that's also the character. 36 00:01:52,280 --> 00:01:56,630 Let's get a variable for our waypoints. 37 00:01:56,630 --> 00:01:58,910 I'll make the variable a lowercase w. 38 00:01:58,910 --> 00:02:08,570 P Yes, we'll get char ralph dot waypoints and then I'll do a get children to get individual waypoints. 39 00:02:08,570 --> 00:02:11,480 And this is going to be a table storing those waypoints. 40 00:02:12,380 --> 00:02:16,010 Now, I need the humanoid of Ralph, so I'll just call that him. 41 00:02:16,010 --> 00:02:17,150 We have our char. 42 00:02:17,150 --> 00:02:20,360 We could do a wait for child, but Ralph is just sitting there. 43 00:02:20,360 --> 00:02:22,490 We're not doing any responding or anything. 44 00:02:22,490 --> 00:02:25,430 If we start doing that, we will do a wait for child. 45 00:02:25,430 --> 00:02:27,610 I'm just going to do dot humanoid, right? 46 00:02:27,620 --> 00:02:28,400 It's easier. 47 00:02:28,580 --> 00:02:30,290 Oh, one more variable. 48 00:02:30,290 --> 00:02:32,660 We need an index. 49 00:02:32,840 --> 00:02:33,980 Set it to one. 50 00:02:33,980 --> 00:02:40,250 The index is going to determine in our waypoints which waypoint we're moving to. 51 00:02:40,280 --> 00:02:43,100 So this will be one, two, three, four. 52 00:02:43,100 --> 00:02:56,690 So let's get let's get the humanoid and then we'll get this oh colon move to we'll get our W piece, 53 00:02:56,690 --> 00:03:06,290 access the WP tables with those square brackets using the ID X variable and then we'll have possession. 54 00:03:06,290 --> 00:03:06,890 Right. 55 00:03:06,890 --> 00:03:11,150 So this W piece is storing all four of our points. 56 00:03:11,150 --> 00:03:17,150 Index starts out at one, so it's going to say Oh WP that's a variable for that. 57 00:03:17,150 --> 00:03:18,170 Oh, there we go. 58 00:03:18,170 --> 00:03:19,790 But I really need to go to the position. 59 00:03:20,030 --> 00:03:20,900 Dot position. 60 00:03:20,900 --> 00:03:21,680 Cool. 61 00:03:21,740 --> 00:03:26,720 Let's go ahead and wait a little bit to get in the game to see Ralph actually move. 62 00:03:26,720 --> 00:03:29,780 So I'll wait 5 seconds, then I'll move to my first point. 63 00:03:36,530 --> 00:03:37,520 And where is he? 64 00:03:38,560 --> 00:03:39,530 There he goes. 65 00:03:39,550 --> 00:03:40,900 He ran up to the point. 66 00:03:41,350 --> 00:03:41,860 All right. 67 00:03:41,860 --> 00:03:42,780 That's pretty cool. 68 00:03:42,790 --> 00:03:47,980 Let's get him to go to the points over and over and over again like a patrol. 69 00:03:48,010 --> 00:03:57,400 Now, move to has this fires off this cool event called Move to Finish when the NPC actually arrives. 70 00:03:57,640 --> 00:04:03,790 There's a timeout there too, so you have to make the move to less than 6 seconds. 71 00:04:03,790 --> 00:04:05,380 I believe it is now. 72 00:04:05,380 --> 00:04:07,640 Or you'll get the timeout and I'll just stop you. 73 00:04:07,640 --> 00:04:11,500 I'll have to do something new, but we're not going to make our waypoints that far away. 74 00:04:11,500 --> 00:04:13,240 We won't run into that trouble. 75 00:04:13,240 --> 00:04:19,930 But if I do a humanoid or HUME dot move to finish, this is going to fire. 76 00:04:19,930 --> 00:04:26,890 When we arrive to our location, I will connect that to an anonymous function. 77 00:04:26,890 --> 00:04:34,780 And then that function I'm going to get my index and then I'll increase it. 78 00:04:34,780 --> 00:04:37,020 I'll do a plus equals one. 79 00:04:37,030 --> 00:04:40,360 But if I get more than four, I've got to go back to one. 80 00:04:40,360 --> 00:04:40,870 Right? 81 00:04:40,870 --> 00:04:42,220 I don't want to go too high. 82 00:04:42,220 --> 00:04:51,940 So if I say if index is greater than the number of points in WPX or the number of elements in WP'S index 83 00:04:51,940 --> 00:04:53,680 will now equal one again. 84 00:04:53,800 --> 00:04:56,500 So we're just going to keep increasing it until we get too high. 85 00:04:56,530 --> 00:04:57,820 Then we'll start over at one. 86 00:04:58,060 --> 00:05:07,600 Then I'll just get my HUME move to WPX, whatever that next index is. 87 00:05:07,600 --> 00:05:10,480 So it might be like two wickets. 88 00:05:10,480 --> 00:05:14,950 The four is going to go back to one and I'll say possession needs to go to the possession. 89 00:05:14,950 --> 00:05:19,030 So now we have our patrol working. 90 00:05:19,330 --> 00:05:20,410 It doesn't do anything. 91 00:05:20,410 --> 00:05:21,560 He doesn't stop or anything. 92 00:05:21,610 --> 00:05:22,870 He just keeps running. 93 00:05:23,590 --> 00:05:24,310 Let's see. 94 00:05:24,310 --> 00:05:25,660 There he goes. 95 00:05:26,410 --> 00:05:32,290 And let's go ahead and bring our bring up our output window, make sure we don't have any errors. 96 00:05:32,890 --> 00:05:34,720 I think he's going pretty good. 97 00:05:35,090 --> 00:05:39,100 It's kind of fast for a patrol, though, if he's not moving at all. 98 00:05:39,190 --> 00:05:43,960 Check down here and also check his humanoid root part to make sure it's not anchored. 99 00:05:43,990 --> 00:05:45,550 That's the most common error. 100 00:05:45,580 --> 00:05:46,690 Let's slow them down. 101 00:05:46,690 --> 00:05:47,110 So he's more. 102 00:05:47,260 --> 00:05:49,040 More like a stroll, right? 103 00:05:49,060 --> 00:05:53,770 More of a patrol speed right under the humanoid. 104 00:05:53,770 --> 00:05:58,660 We can do that anywhere under where we decline, where we declare. 105 00:05:58,660 --> 00:06:00,160 HUME We could do this. 106 00:06:00,160 --> 00:06:09,790 HUME Dot walk speed, and then let's make it like eight as normally 16. 107 00:06:10,390 --> 00:06:11,110 Let's try it. 108 00:06:16,260 --> 00:06:17,220 Here we go. 109 00:06:19,150 --> 00:06:21,390 Yeah, that's more of a patrol. 110 00:06:21,860 --> 00:06:23,850 Looks like he's ready for business. 111 00:06:25,180 --> 00:06:25,720 All right. 112 00:06:25,720 --> 00:06:26,800 Pretty cool. 113 00:06:26,800 --> 00:06:29,200 And we'll add to that in the next video.